package com.zwb.demo.easyweb.modules.config.controller;

import com.zwb.demo.easyweb.common.entity.response.ResponseResult;
import com.zwb.demo.easyweb.modules.config.service.FormComponentService;
import com.zwb.demo.easyweb.modules.config.vo.FormComponentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "表单控件管理接口" ,description = "表单控件管理接口")
public class FormComponentController {

    private final FormComponentService formComponentService;


    @Autowired
    public FormComponentController(FormComponentService formComponentService) {
        this.formComponentService = formComponentService;
    }

    @GetMapping("/config/formComponent")
    @ApiOperation(value = "查询所有表单控件类型")
    public ResponseResult findAll(){
        return formComponentService.findAll();
    }

    @PutMapping("/config/formComponent")
    @ApiOperation(value = "新增或修改表单控件类型")
    public ResponseResult addOne(@RequestBody FormComponentVO vo){
        return formComponentService.addOrUpdateOne(vo);
    }

    @DeleteMapping("/config/formComponent/{uuid}")
    @ApiOperation(value = "删除表单控件类型")
    public ResponseResult deleteOne(@PathVariable String uuid){
        return formComponentService.deleteOne(uuid);
    }

}
